#ifndef MP3ITEM_H
#define MP3ITEM_H

#include "blogitem.h"
#include "remotefiledownloader.h"
#include <QDomElement>

// --------------- //
// CLASS : MP3Item //
// --------------- //
class Mp3Item : public BlogItem
{
public:
    //Constructor
    Mp3Item(QString name, const QUrl& url, int host, QSettings* settings = NULL);

    //Constructor from XML
    Mp3Item(const QDomElement& elt, QSettings* settings = NULL);

    //Default processing method (download)
    virtual void defaultProcessing();

    //Download method
    void download();

    //Getters / Setters
    int     getDownloadingStatus() const;
    void    setDownloadingStatus(int status);
    QDate   getDatePosted() const;
    QDir    getDownloadDir() const;

    //Static hosting types
    static const int hostedDirectly = 1;
    static const int hostedOnZippyShare = 2;

    //Static downloading status
    static const int notDownloaded = 1;
    static const int downloading = 2;
    static const int downloaded = 3;
    static const int downloadError = 0;

    //To XML
    QDomElement toDomElt();

protected:
    void init();
    void downloadDirect();
    void downloadZippyshare();

private:
    int         _host;
    int         _downloadingStatus; //int pour bool : cas ou DL en cours (0,1,2)
    QDate       _datePosted;

    RemoteFileDownloader* _downloader;
};


// --------------------- //
// CLASS : MP3Downloader //
// --------------------- //
class Mp3Downloader : public RemoteFileDownloader
{
    Q_OBJECT

public:
    Mp3Downloader(const Mp3Item* const mp3);

private slots:
    void downloadFinished();

private:
    Mp3Item* _mp3Item;
};


#endif // MP3ITEM_H
